﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace WebSite
{
    public class SQLAccess
    {
        // Fields
        private static string DBConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        public static DataSet GreatDs(string sql)
        {
           SqlDataAdapter adapter = new SqlDataAdapter(sql, DBConnectionString);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet);
            return dataSet;
        }

        // Methods
        public static void DoSql(string sql)
        {

            if (DateTime.Now > DateTime.Parse(Maticsoft.DBUtility.PubConstant.PeriodDate))
            {
                throw new Exception(Maticsoft.DBUtility.PubConstant.SystemException);
            }

            SqlConnection connection = new SqlConnection
            {
                ConnectionString = DBConnectionString
            };
            connection.Open();
            new SqlCommand(sql, connection).ExecuteNonQuery();
            connection.Close();
        }


    }
}